import axios from "axios";
import {COMMENTS_MODULE} from "./_prefix";

/**
 *
 * @param payload 参数：课程号
 */
export const getComments = payload => {
    const { courseId, selectRule } = payload;
    return axios.get(`${COMMENTS_MODULE}/${courseId}`, {params: {selectRule}})
        .then(res => {
            //console.log(res.data);
        return res.data;
    });
};

export const createComments = payload => {
    const {
        title,
        subTitle,
        abstraction,
        courseId,
        uid,
        uname,
    } = payload;
    //console.log(payload);
    return axios
        .post(`${COMMENTS_MODULE}/${courseId}`, {
            title,
            subTitle,
            abstraction,
            courseId,
            uid,
            uname,
        })
        .then(res => {
            return res.data;
        });
};
